package com.ruoyi.project.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import java.util.List;
import com.ruoyi.common.utils.DateUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.project.mapper.ProjectArticleMapper;
import com.ruoyi.project.domain.ProjectArticle;
import com.ruoyi.project.service.IProjectArticleService;

/**
 * 文章Service业务层处理
 *
 * @author lumberer
 * @date 2025-05-10
 */
@Service
public class ProjectArticleServiceImpl extends ServiceImpl<ProjectArticleMapper, ProjectArticle> implements IProjectArticleService {
    @Autowired
    private ProjectArticleMapper projectArticleMapper;

    /**
     * 查询文章
     *
     * @param id 文章主键
     * @return 文章
     */
    @Override
    public ProjectArticle selectProjectArticleById(Long id) {
        return projectArticleMapper.selectProjectArticleById(id);
    }

    /**
     * 查询文章列表
     *
     * @param projectArticle 文章
     * @return 文章
     */
    @Override
    public List<ProjectArticle> selectProjectArticleList(ProjectArticle projectArticle) {
        return projectArticleMapper.selectProjectArticleList(projectArticle);
    }

    /**
     * 新增文章
     *
     * @param projectArticle 文章
     * @return 结果
     */
    @Override
    public int insertProjectArticle(ProjectArticle projectArticle) {
                projectArticle.setCreateTime(DateUtils.getNowDate());
            return projectArticleMapper.insertProjectArticle(projectArticle);
    }

    /**
     * 修改文章
     *
     * @param projectArticle 文章
     * @return 结果
     */
    @Override
    public int updateProjectArticle(ProjectArticle projectArticle) {
                projectArticle.setUpdateTime(DateUtils.getNowDate());
        return projectArticleMapper.updateProjectArticle(projectArticle);
    }

    /**
     * 批量删除文章
     *
     * @param ids 需要删除的文章主键
     * @return 结果
     */
    @Override
    public int deleteProjectArticleByIds(Long[] ids) {
        return projectArticleMapper.deleteProjectArticleByIds(ids);
    }

    /**
     * 删除文章信息
     *
     * @param id 文章主键
     * @return 结果
     */
    @Override
    public int deleteProjectArticleById(Long id) {
        return projectArticleMapper.deleteProjectArticleById(id);
    }
}